import React from 'react'
import store from '../../store/store'
import {getMovieAction} from '../../store/actions/movieAction' 

export default function Movie() {
  const{count} = store.getState().count

  //下面点击发送请求后，把数据传给store，然后给reduce处理，返回给store，通过store.getState拿到数据

  const{movieList} = store.getState().movie

  console.log(movieList,'movieList');

  const getMovieHandle =()=>{
    //点击发送请求，为了方便，发请求api统一管理
    store.dispatch(getMovieAction())
  }


  return (
    <div>
        <br />
        <h2>与count通讯，这里数字是【{count}】</h2>
        <br />
        <h2>电影列表</h2>
        <button onClick={getMovieHandle}>点击获取电影信息</button>

        <ul>
        {
          movieList.map(item => {
            return <li key={item.tvId}>{item.albumName}</li>
          })
        }
      </ul>
    </div>
  )
}
